//
//  MemberViewController.m
//  yemeishe1
//
//  Created by 吴坤金 on 2017/2/28.
//  Copyright © 2017年 yameishe. All rights reserved.
//

#import "MemberViewController.h"

#import "MemberSystemSettingController.h"
#import "MemberUpGradeController.h"
#import "AboutUsController.h"
#import "MemberRechargeController.h"
#import "MemberWithdrawalsController.h"

#import "MemberBasicInfoView.h"

@interface MemberViewController ()
@property (nonatomic) UIScrollView *scrollView;
@property (nonatomic) MemberBasicInfoView *basicInfoView;
@property (nonatomic,weak) IBOutlet UIView *bottomView;
@end

@implementation MemberViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"会员中心";
    [self controllerSetting];
    
   
    
    _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
    [self.view addSubview:_scrollView];
    
    _basicInfoView = [[[NSBundle mainBundle]loadNibNamed:@"MemberBasicInfoView" owner:self options:nil] firstObject];
    [_scrollView addSubview:_basicInfoView];
    
    [_scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self.view);
        make.bottom.equalTo(_bottomView.mas_top).offset(0);
    }];
    
    [_bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.equalTo(self.view);
        make.bottom.equalTo(self.view).offset(-50);
    }];
    [_basicInfoView.rechargeBtn addTarget:self action:@selector(onTouchRecharge:) forControlEvents:UIControlEventTouchUpInside];
    [_basicInfoView.drawalsBtn addTarget:self action:@selector(onTouchDrawals:) forControlEvents:UIControlEventTouchUpInside];
    
    
}
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    self.tabBarController.tabBar.hidden=NO;
//    self.hidesBottomBarWhenPushed = YES;
    [self.view layoutIfNeeded];
    
}
-(void)viewWillDisappear:(BOOL)animated {
    // 反注册键盘
    [super viewWillDisappear:YES];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(IBAction)onTouchButton:(UIButton *)sender
{
    switch (sender.tag) {
        case 0:
        {
            NSLog(@"关于我们");
            AboutUsController *vc = [[UIStoryboard storyboardWithName:@"Member" bundle:nil] instantiateViewControllerWithIdentifier:@"AboutUsController"];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 1:
        {
            NSLog(@"推荐好友");
            [self onTouchShare];
        }
            break;
        case 2:
        {
            NSLog(@"系统设置");
            
           MemberSystemSettingController *vc = [[UIStoryboard storyboardWithName:@"Member" bundle:nil] instantiateViewControllerWithIdentifier:@"MemberSystemSettingController"];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 3:
        {
            NSLog(@"高级会员");
            MemberUpGradeController *vc = [[UIStoryboard storyboardWithName:@"Member" bundle:nil] instantiateViewControllerWithIdentifier:@"MemberUpGradeController"];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        default:
            break;
    }
}

-(IBAction)onTouchRecharge:(id)sender
{
    MemberRechargeController *vc = [[UIStoryboard storyboardWithName:@"Member" bundle:nil] instantiateViewControllerWithIdentifier:@"MemberRechargeController"];
    [self.navigationController pushViewController:vc animated:YES];
}
-(IBAction)onTouchDrawals:(id)sender
{
    MemberWithdrawalsController *vc = [[UIStoryboard storyboardWithName:@"Member" bundle:nil] instantiateViewControllerWithIdentifier:@"MemberWithdrawalsController"];
    [self.navigationController pushViewController:vc animated:YES];
}

-(void)onTouchShare
{
//    NSString *title = _model.title;
//    NSString *url = _model.link;
//    UIImage *image = nil;
//    image = [[YYImageCache sharedCache] getImageForKey:_model.image];
//    if (title.length==0) {
//        title = [weak_self.webView stringByEvaluatingJavaScriptFromString:@"document.title"];
//    }
//    if (url.length==0) {
//        url = [weak_self.webView stringByEvaluatingJavaScriptFromString:@"window.location.href"];
//    }
//    if (!image) {
//        image = [UIImage imageFromView:_webView];
//    }
//    
//    [MobShareHelper shareTo:item image:image title:title url:url content:nil completion:^(NSString *msg, NSError *error) {
//        if (error) {
//            [SVProgressHUD showErrorWithStatus:error.localizedFailureReason];
//        } else {
//            [SVProgressHUD showSuccessWithStatus:msg];
//        }
//    }];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
